/**
 * @see https://umijs.org/zh-CN/plugins/plugin-access
 * */
// export default function access(initialState: { currentUser?: API.CurrentUser } | undefined) {
//   const { currentUser } = initialState ?? {};
//   console.log('currentUser', currentUser);

//   return {
//     canAdmin: currentUser && currentUser.access === 'admin',
//   };
// }

export default function access() {
  const loginInfo: any = JSON.parse(localStorage.getItem('userInfo') as any);
  // console.log(loginInfo);
  const role = loginInfo?.userRoles[0]?.role;

  // console.log(role);

  return {
    canAdmin: role?.name === '管理员' && role?.type === 1,
  };
}
